POV-Ray : Newsgroups : povray.general : object oriented features : Re: object oriented features Server Time
28 Jul 2024 16:28:41 EDT (-0400)
  Re: object oriented features  
From: Mikael Carneholm
Date: 21 Aug 2000 08:04:39
Message: <39A11AD5.5A347EF4@ida.utb.hb.se>
Chris Huff wrote:

> Still, what *is* the location? A sphere has a center, but what is the
> center of a cone? The middle of the bounding box? The center of gravity?
> What is the "location" of an infinite plane? A complex mesh or CSG?
> Each object should have it's own variables available, but a single
> "location" variable for all of them isn't possible. Maybe a
> GetLocation() method for all objects in the finite object portion of the
> heirarchy, but you still have to define the location of an arbitrary
> object.
>

I apologize if I was unclear about this. Your previous post made me realize
that it's better to have object type specific attributes (like .origin for
sphere, .top & .bottom for cylinder, .corner1 & .corner2 for box, .normal
and .distance for plane, etc.)  which relate to the initial values given
when the object was created, and then separate .translation and .rotation
attributes (alt. getTranslation() & getRotation() methods). Collecting
information about an objects whereabouts should then be no problem - if the
.translation and .rotation attributes correspond to the respective values in
the transformation matrix of the object. Again, an example:

#declare ABox = box{
  <-1,-1,-1>,
  <1,1,1>
  translate <5,1,0>
}

Then:

ABox.corner1 = <-1,-1,-1>
ABox.corner2 = <1,1,1>
ABox.translation = <5,1,0>

...which means the exact position of "corner1" can be retrieved by

#declare corner1_pos = ABox.corner1 + ABox.translation;

I think this makes more sense, as an object always is created with some
parameters, and then translated/rotated various amounts. It should thus be
quite logical to collect info about an object my reversing the creation
process; think of it as setting the values at creation and getting the same
values at a later point.

Btw, check the VPython pages that ingo found:

http://virtualphoton.pc.cc.cmu.edu/projects/visual/
http://cil.andrew.cmu.edu/projects/visual/vpythonprog.htm

Not very far from POV-Script actually - except that it is object oriented,
of course.

----------------------------------------------------
Mikael Carneholm, B.Sc.
Dep. of Computer Science and Business Administration


Personal homepage:
http://www.studenter.hb.se/~arch
E-mail:
sa9### [at] idautbhbse


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.